#ifndef __CHANNEL_HPP__
#define __CHANNEL_HPP__

#include <iostream>
#include <string>
#include <unistd.h>

using namespace std;
//先描述;相当于是master
class Channel
{
public:
    Channel(int wfd,pid_t who)
    :_wfd(wfd)
    ,_who(who)
    {
        //channel-3-1234  通过3号描述符给1234的子进程里读
        _name = "Channel-"+to_string(wfd)+to_string(who);
    }
    string Name()
    {
        return _name;
    }
    void send(int cmd)//发送任务
    {
        write(_wfd,&cmd,sizeof(cmd));
    }
    void close()
    {
        close();
    }
    pid_t Id()
    {
        return _who;
    }
    ~Channel()
    {}
private:
    int _wfd;//写端
    string _name;
    pid_t _who;
};

#endif